package com.zw.yzk.kabu.view.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.zw.yzk.kabu.R;
import com.zw.yzk.kabu.adapter.CosImageListAdapter;
import com.zw.yzk.kabu.base.BaseActivity;
import com.zw.yzk.kabu.constant.ActivityConstant;
import com.zw.yzk.kabu.management.ToolbarBuilder;
import com.zw.yzk.kabu.model.PublishImageModel;

import java.util.List;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * Created by zhanwei on 2017/1/3.
 */

public class EditCosImageActivity extends BaseActivity {

    @Bind(R.id.cos_images)
    RecyclerView imageList;

    private CosImageListAdapter adapter;

    @Override
    public int getLayoutId() {
        return R.layout.activity_edit_cos_image;
    }

    @Override
    public void iniToolbar(BaseActivity activity) {
    }

    @Override
    public void initComponent() {
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initRecyclerView();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @OnClick(R.id.complete)
    public void complete() {
        Intent intent = new Intent();
        intent.putParcelableArrayListExtra(ActivityConstant.EDIT_COS_IMAGE_COMPLETE, adapter.getImageList());
        setResult(RESULT_OK, intent);
        finish();
    }

    /**
     * 初始化recyclerView
     */
    private void initRecyclerView() {
        imageList.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
        List<PublishImageModel> modelList = getIntent().getParcelableArrayListExtra(ActivityConstant.EDIT_COS_IMAGE);
        adapter = new CosImageListAdapter(modelList);
        imageList.setAdapter(adapter);
    }

}
